package br.com.caelum.vraptor.controller;

import java.util.List;

import javax.inject.Inject;

import br.com.caelum.vraptor.Controller;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.dao.PerfilDAO;
import br.com.caelum.vraptor.dao.GenericDAO;
import br.com.caelum.vraptor.entidades.Perfil;

@Controller
public class PerfilController {
	
	@Inject
	private Result result;
	
	@Inject
	private GenericDAO<Perfil> dao;
	
	
	public void add(){
		
	}
	
	
	public List<Perfil> list(){
		
		return dao.find();
		
	}
	
	
	public void save(Perfil perfil){
		
		dao.save(perfil);
		
		result.redirectTo(this).list();
	}
	
	public Perfil edit(Integer id){
		return dao.find(id);
	}
	
	public void delete(int id){
		Perfil perfil = new Perfil();
		perfil.setId(id);
		dao.delete(perfil);
		result.redirectTo(this).list();
	}
	
}
